#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
	char *str = (char*)malloc(1024);
	printf("please input str:\n");
	gets(str);

	char *start = str;
	char *end = str;
	int max = 0;
	char word[128] = {'\0'};
	while (1)
	{
		while (*end != ',' && *end != ' ' && *end != '.')
		{
			end++;
		}
		if (max < end-start)
		{
			max = end-start;
			//将指定长度的字符串拷贝到目的地
			strncpy(word, start, end-start);
		}
		if ('.' == *end)
		{
			break;
		}
		start = ++end;
	}
	printf("max word:%s, len=%d\n", word, max);

	return 0;
}
